/*
 * BreadCrum.fx
 *
 * Created on Aug 14, 2009, 4:56:07 PM
 */

package foldervisualizer;

import javafx.scene.CustomNode;
import javafx.scene.Node;
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.paint.*;
import javafx.scene.shape.Rectangle;
import javafx.scene.Group;
import javafx.scene.Cursor;

/**
 * @author paul
 */

public class BreadCrum extends CustomNode{
    public var folders : String[];

    public var itemClicked : function(item : String, visitedDirs : String[]);

    public override function create() : Node {
        HBox {
            content: bind
                for(folder in folders) {
                  var color = Color.WHITE;
                  var txt : Text;
                   Group {
                       content: [
                               Rectangle {
                                       x: bind txt.boundsInParent.minX, y: txt.boundsInParent.minY
                                       width: bind txt.boundsInParent.width, height: txt.boundsInParent.height
                                       fill: bind color;
                                       onMouseEntered: function(evt) {
                                           color = Color.YELLOW;
                                       }

                                       onMouseExited: function(evt) {
                                           color = Color.WHITE;
                                       }

                                       onMouseClicked: function(evt) {
                                           var newFolder : String;
                                           var newFolders : String[];


                                           for(f in folders[0..indexof folder]) {
                                               
                                               newFolder += "{f}/";
                                               insert f into newFolders;
                                           }

                                           itemClicked(newFolder, folders[0..indexof folder]);
                                           

                                       }



                               }



                            txt = Text {
                                font : Font {
                                          size: 14
                                       }

                                fill: Color.BLACK;
                                content: "{folder} / "

                            }
                       ]

                        
                   }





                }

                


             
        }
    }

}
